﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using System.Diagnostics.Contracts;

namespace YasharEl.Infrastructure.ProcessEngine.DomainModel.WorkflowManagement
{
    [ContractClass(typeof(WorkflowExecutionManagerContract))]
    public interface IWorkflowExecutionManager
    {
        WorkflowApplication StartWorkflowSuspended(string workflowXaml, Dictionary<string, object> inputs, WorkflowIdentity workflowIdentity);

        WorkflowApplication RunWorkflow(WorkflowApplication workflowApplication);

        WorkflowApplication RetriveWorkflowInstance(string workflowXaml, Guid workflowInstanceId, WorkflowIdentity workflowIdentity);
    }

    [ContractClassFor(typeof(IWorkflowExecutionManager))]
    internal abstract class WorkflowExecutionManagerContract : IWorkflowExecutionManager
    {
        public WorkflowApplication StartWorkflowSuspended(string workflowXaml, Dictionary<string, object> inputs, WorkflowIdentity workflowIdentity)
        {
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(workflowXaml), "workflowXaml could not be null or empty.");
            Contract.Requires<ArgumentNullException>(workflowIdentity != null, "workflowIdentity could not be null.");

            return default(WorkflowApplication);
        }

        public WorkflowApplication RunWorkflow(WorkflowApplication workflowApplication)
        {
            Contract.Requires<ArgumentNullException>(workflowApplication != null, "workflowApplication could not be null.");
            return default(WorkflowApplication);
        }

        public WorkflowApplication RetriveWorkflowInstance(string workflowXaml, Guid workflowInstanceId, WorkflowIdentity workflowIdentity)
        {
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(workflowXaml), "workflowXaml could not be null or empty.");
            Contract.Requires<ArgumentNullException>(workflowInstanceId != Guid.Empty, "workflowInstanceId could not be null or empty guid.");
            Contract.Requires<ArgumentNullException>(workflowIdentity != null, "workflowIdentity could not be null.");

            return default(WorkflowApplication);
        }
    }
}
